package main

import (
	"fmt"

	"task/config"
	"task/driver"
	service "task/service/admin"

	log "github.com/sirupsen/logrus"
)

func main() {
	// 初始化DB
	driver.InitEngine()
	defer driver.Engine.Close()
	// 初始化雪花生成器
	driver.InitSnowNode()
	// 初始化消息队列组件
	driver.InitPulsarClient()
	defer driver.PulsarClient.Close()
	// 初始化调度消息生产者
	driver.InitDispatchProducer()
	defer driver.DispatchProducer.Close()
	// 创建并运行gin服务
	svr := service.NewServer()
	addr := fmt.Sprintf(":%d", config.Conf.TaskAdmin.Port)
	if err := svr.Run(addr); err != nil {
		log.Panic("Failed to start server:", err)
	}
}
